﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySQLDriverCS;
using System.Data.Common;

namespace fitment.login
{
    public partial class Login : Form
    {
        public Login()
        {
            InitializeComponent();
            
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (_account.Text == "")
            {
                MessageBox.Show("account can't be null ");
                return;
            }
            if (_password.Text == "")
            {
                MessageBox.Show("password can't be null "); 
                return;
            }
            MySQLConnection conn = null;
            conn = new MySQLConnection(new MySQLConnectionString("localhost", "fitment", "root", "123456").AsString);
            conn.Open();  
            string sql = "select * from User where user_account='"+_account.Text+"' and user_password='"+_password.Text+"'";

            MySQLCommand cmd = new MySQLCommand(sql, conn);

            DbDataReader sdr = cmd.ExecuteReader();
            if (sdr.HasRows)
            {
                
                this.Close(); 
            }
            else
            {
               MessageBox.Show("用户名或密码错误！");
            } 
           
            conn.Close();
             


        }
  
         

        private void Login_Load(object sender, EventArgs e)
        {

        }
    }
}
